package edu.up.globalizacao;

import java.util.Locale;
import java.util.ResourceBundle;

public class LabelLocale 
{
	private static LabelLocale labelLocale;
	
	private static ResourceBundle language;
	private static ResourceBundle language_pt_BR;
	private static ResourceBundle language_en_US;
	private static ResourceBundle language_es_ES;
		
	private LabelLocale() {
		language = ResourceBundle.getBundle("language", Locale.getDefault());
		language_pt_BR = ResourceBundle.getBundle("language_pt_BR");
		language_en_US = ResourceBundle.getBundle("language_en_US");
		language_es_ES = ResourceBundle.getBundle("language_es_ES");
	}
	
	public static LabelLocale getInstance() 
	{
		if( labelLocale == null )
			labelLocale = new LabelLocale();
		return labelLocale;		
	}	
	
	public ResourceBundle getBundle(String locale) 
	{
		if( locale.equals( "en_US" ) ) 
			return language_en_US;
		else if( locale.equals("pt_BR" ) )
			return language_pt_BR;
		else if( locale.equals("es_ES" ) )
			return language_es_ES;		
		else
			return language;
	}
	
	public void refresh() {
		labelLocale = null;
	}		
}